/**
 * Copyright (c)2014 快诺迅汇(长沙)网络技术股份有限公司。
 * 版权所有
 */
package com.linkpow.smartelevator.config;

import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.time.LocalDate;
import java.time.LocalDateTime;


/**
 * @ClassName Swagger
 * @Description Swagger2配置
 * @Author Administrator
 * @Date 2019/11/25 13:39
 * @Version 1.0
 */
@Configuration
@EnableSwagger2
public class Swagger {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .directModelSubstitute(LocalDateTime.class, String.class)
                .directModelSubstitute(LocalDate.class, String.class)
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo(){
        Contact contact = new Contact("智慧电梯", "", "");
        return new ApiInfoBuilder().title("智慧电梯API服务接口文档")
                .description("智慧电梯API服务接口文档描述以及在线测试")
                //.termsOfServiceUrl("http://www.***.com")
                .contact(contact)
                .version("1.0.0")
                .license("长沙凌波信息技术有限公司")
                //.licenseUrl("http://www.***.com")
                .build();
    }
}
